package com.xf.handler;

import com.xf.common.core.domain.DmpResult;
import com.xf.common.core.handler.BaseExceptionHandler;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author xufeng
 */
@RestControllerAdvice
@Order(value = Ordered.HIGHEST_PRECEDENCE)
public class GlobalExceptionHandler extends BaseExceptionHandler {

    @ExceptionHandler(IllegalArgumentException.class)
    @ResponseBody
    public DmpResult handleIllegalArgumentException(IllegalArgumentException e) {
        return DmpResult.failed(e.getMessage());
    }
}
